/*     */ package com.lmpop.trade.ti_organize;
/*     */ 
/*     */ import com.lmpop.frame.QueryList;
/*     */ import com.lmpop.frame.SysMap;
/*     */ import com.lmpop.frame.TradeInterf;
/*     */ import com.lmpop.frame.dao.DbmInterf;
/*     */ import com.lmpop.frame.exp.ApplicationException;
/*     */ import java.util.Hashtable;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class Ti_organizeInfo
/*     */   implements TradeInterf
/*     */ {
/*     */   QueryList queryList;
/*     */ 
/*     */   public Ti_organizeInfo()
/*     */   {
/*  17 */     this.queryList = new QueryList();
/*     */   }
/*     */ 
/*     */   public SysMap insert(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  27 */     Ti_organize ti_organize = new Ti_organize();
/*  28 */     ti_organize.setCust_id(map.getString("session_cust_id"));
/*  29 */     ti_organize.setOrg_id(map.getString("org_id"));
/*  30 */     ti_organize.setOrg_name(map.getString("org_name"));
/*  31 */     ti_organize.setUp_org_id(map.getString("up_org_id"));
/*  32 */     ti_organize.setOrg_class(map.getString("org_class"));
/*  33 */     ti_organize.setOrg_desc(map.getString("org_desc"));
/*  34 */     ti_organize.setRemark(map.getString("remark"));
/*     */ 
/*  36 */     String result_code = "0";
/*     */     try {
/*  38 */       insert(dbmMgr, ti_organize);
/*     */     } catch (ApplicationException e) {
/*  40 */       e.printStackTrace();
/*  41 */       result_code = "1";
/*     */     }
/*  43 */     map.setString("result_code", result_code);
/*  44 */     return map;
/*     */   }
/*     */ 
/*     */   public void insert(DbmInterf dbmMgr, Ti_organize ti_organize)
/*     */     throws ApplicationException
/*     */   {
/*  53 */     dbmMgr.update("insertTi_organize", ti_organize);
/*     */   }
/*     */ 
/*     */   public SysMap delete(DbmInterf dbmMgr, SysMap map)
/*     */   {
/*  63 */     String pkid_string = map.getString("pkid");
/*  64 */     String result_code = "0";
/*  65 */     String org_ids = "";
/*     */     try {
/*  67 */       if (!pkid_string.equals("")) {
/*  68 */         String[] pkStr = pkid_string.split("\\|");
/*  69 */         StringBuffer org_ = new StringBuffer();
/*  70 */         for (int i = 0; i < pkStr.length; i++) {
/*  71 */           if (!pkStr[i].equals("")) {
/*  72 */             org_.append(pkStr[i] + "|");
/*  73 */             org_.append(getAllCatAttr(pkStr[i]));
/*     */           }
/*     */         }
/*  76 */         org_ids = org_.toString();
/*  77 */         String[] orgIds = org_.toString().split("\\|");
/*  78 */         for (String id : orgIds)
/*  79 */           delete(dbmMgr, id);
/*     */       }
/*     */     }
/*     */     catch (ApplicationException e) {
/*  83 */       e.printStackTrace();
/*  84 */       result_code = "1";
/*     */     }
/*  86 */     map.setString("org_ids", org_ids);
/*  87 */     map.setString("result_code", result_code);
/*  88 */     return map;
/*     */   }
/*     */ 
/*     */   public String getAllCatAttr(String pk)
/*     */   {
/*  99 */     StringBuffer catAttr = new StringBuffer();
/* 100 */     List sonlist = getSonById(pk);
/* 101 */     if ((sonlist != null) && (sonlist.size() > 0)) {
/* 102 */       for (int i = 0; i < sonlist.size(); i++) {
/* 103 */         Hashtable sonMap = (Hashtable)sonlist.get(i);
/* 104 */         String org_id = "";
/* 105 */         if (sonMap.get("org_id") != null) {
/* 106 */           org_id = sonMap.get("org_id").toString();
/*     */         }
/* 108 */         if (!org_id.equals("")) {
/* 109 */           catAttr.append(org_id + "|");
/* 110 */           if (checkSonById(org_id).booleanValue()) {
/* 111 */             catAttr.append(getAllCatAttr(org_id));
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/* 116 */     return catAttr.toString();
/*     */   }
/*     */ 
/*     */   public void delete(DbmInterf dbmMgr, String pkid)
/*     */     throws ApplicationException
/*     */   {
/* 125 */     dbmMgr.update("deleteTi_organize", pkid);
/*     */   }
/*     */ 
/*     */   public List getSonById(String pk)
/*     */   {
/* 132 */     return this.queryList.getList("checkTi_OrganizeSonByPk", pk);
/*     */   }
/*     */ 
/*     */   public SysMap update(DbmInterf dbmMgr, SysMap map)
/*     */   {
/* 143 */     Ti_organize ti_organize = new Ti_organize();
/* 144 */     ti_organize.setCust_id(map.getString("session_cust_id"));
/* 145 */     ti_organize.setOrg_id(map.getString("org_id"));
/* 146 */     ti_organize.setOrg_name(map.getString("org_name"));
/* 147 */     ti_organize.setUp_org_id(map.getString("up_org_id"));
/* 148 */     ti_organize.setOrg_class(map.getString("org_class"));
/* 149 */     ti_organize.setOrg_desc(map.getString("org_desc"));
/* 150 */     ti_organize.setRemark(map.getString("remark"));
/*     */ 
/* 152 */     String result_code = "0";
/*     */     try {
/* 154 */       update(dbmMgr, ti_organize);
/*     */     } catch (ApplicationException e) {
/* 156 */       e.printStackTrace();
/* 157 */       result_code = "1";
/*     */     }
/* 159 */     map.setString("result_code", result_code);
/* 160 */     return map;
/*     */   }
/*     */ 
/*     */   public void update(DbmInterf dbmMgr, Ti_organize ti_organize)
/*     */     throws ApplicationException
/*     */   {
/* 171 */     dbmMgr.update("updateTi_organize", ti_organize);
/*     */   }
/*     */ 
/*     */   public List getListByPage(Object obj, int start, int limit)
/*     */   {
/* 183 */     Map params = (Hashtable)obj;
/* 184 */     if (start == 0)
/* 185 */       start = 0;
/*     */     else {
/* 187 */       start = (start - 1) * limit;
/*     */     }
/*     */ 
/* 190 */     params.put("start", Integer.valueOf(start));
/* 191 */     params.put("limit", Integer.valueOf(limit));
/*     */ 
/* 193 */     return this.queryList.getList("getTi_organizeList", params);
/*     */   }
/*     */ 
/*     */   public int getCountByObj(Object obj)
/*     */   {
/* 205 */     Map params = (Hashtable)obj;
/* 206 */     List list = this.queryList.getList("getTi_organizeCount", params);
/* 207 */     int count = 0;
/* 208 */     if ((list != null) && (list.size() > 0)) {
/* 209 */       Hashtable newsMap = (Hashtable)list.get(0);
/* 210 */       if ((newsMap.get("count") != null) && (!newsMap.get("count").toString().equals(""))) {
/* 211 */         count = Integer.parseInt(newsMap.get("count").toString());
/*     */       }
/*     */     }
/* 214 */     return count;
/*     */   }
/*     */ 
/*     */   public List getListByPk(String pk)
/*     */   {
/* 223 */     return this.queryList.getList("getTi_organizeByPk", pk);
/*     */   }
/*     */ 
/*     */   public int checkChildren(String cust_id, String up_org_id)
/*     */   {
/* 234 */     Ti_organize ti_organize = new Ti_organize();
/* 235 */     ti_organize.setCust_id(cust_id);
/* 236 */     ti_organize.setUp_org_id(up_org_id);
/* 237 */     List list = this.queryList.getList("check_Children", ti_organize);
/* 238 */     int size = 0;
/* 239 */     if ((list != null) && (list.size() > 0)) {
/* 240 */       size = 1;
/*     */     }
/* 242 */     return size;
/*     */   }
/*     */ 
/*     */   public int judgeOrganizeByName(String cust_id, String org_name, String org_class)
/*     */   {
/* 255 */     Ti_organize ti_organize = new Ti_organize();
/* 256 */     ti_organize.setCust_id(cust_id);
/* 257 */     ti_organize.setOrg_name(org_name);
/* 258 */     ti_organize.setOrg_class(org_class);
/* 259 */     List list = this.queryList.getList("judge_Organize_Name", ti_organize);
/* 260 */     int size = 0;
/* 261 */     if ((list != null) && (list.size() > 0)) {
/* 262 */       size = 1;
/*     */     }
/* 264 */     return size;
/*     */   }
/*     */ 
/*     */   public String getOrganizeByUpIdSelect(String cust_id, String up_org_id)
/*     */   {
/* 275 */     Ti_organize ti_organize = new Ti_organize();
/* 276 */     ti_organize.setCust_id(cust_id);
/* 277 */     ti_organize.setUp_org_id(up_org_id);
/* 278 */     List orglist = this.queryList.getList("check_Children", ti_organize);
/* 279 */     String org_id = ""; String org_name = ""; String org_select = "";
/* 280 */     if ((orglist != null) && (orglist.size() > 0)) {
/* 281 */       for (int i = 0; i < orglist.size(); i++) {
/* 282 */         Hashtable map = (Hashtable)orglist.get(i);
/* 283 */         if (map.get("org_name") != null) {
/* 284 */           org_name = map.get("org_name").toString();
/*     */         }
/* 286 */         if (map.get("org_id") != null) {
/* 287 */           org_id = map.get("org_id").toString();
/*     */         }
/* 289 */         org_select = org_select + "<option value=" + org_id + ">" + org_name + "</option>";
/*     */       }
/*     */     }
/*     */ 
/* 293 */     return org_select;
/*     */   }
/*     */ 
/*     */   public Hashtable getOrganizeByUpId(String cust_id, String up_org_id)
/*     */   {
/* 304 */     Hashtable orgMap = new Hashtable();
/*     */ 
/* 306 */     Ti_organize ti_organize = new Ti_organize();
/* 307 */     ti_organize.setCust_id(cust_id);
/* 308 */     ti_organize.setUp_org_id(up_org_id);
/*     */ 
/* 310 */     List list = this.queryList.getList("check_Children", ti_organize);
/*     */ 
/* 312 */     if ((list != null) && (list.size() > 0)) {
/* 313 */       for (int i = 0; i < list.size(); i++) {
/* 314 */         Hashtable map = (Hashtable)list.get(i);
/* 315 */         String org_id = map.get("org_id").toString();
/* 316 */         String org_name = map.get("org_name").toString();
/* 317 */         orgMap.put(org_id, org_name);
/*     */       }
/*     */     }
/* 320 */     return orgMap;
/*     */   }
/*     */ 
/*     */   public Boolean checkSonById(String pk)
/*     */   {
/* 331 */     List catList = this.queryList.getList("check_org_Son", pk);
/* 332 */     if ((catList != null) && (catList.size() > 0)) {
/* 333 */       return Boolean.valueOf(true);
/*     */     }
/* 335 */     return Boolean.valueOf(false);
/*     */   }
/*     */ 
/*     */   public String getOrgNameById(String org_id)
/*     */   {
/* 346 */     List orgList = this.queryList.getList("get_OrgName_Id", org_id);
/* 347 */     String org_name = "";
/* 348 */     Hashtable orgMap = new Hashtable();
/* 349 */     if ((orgList != null) && (orgList.size() > 0)) {
/* 350 */       orgMap = (Hashtable)orgList.get(0);
/* 351 */       if (orgMap.get("org_name") != null)
/* 352 */         org_name = orgMap.get("org_name").toString();
/*     */     }
/* 354 */     return org_name;
/*     */   }
/*     */ 
/*     */   public String getUp_org_id(String org_id)
/*     */   {
/* 359 */     String up_org_id = "";
/* 360 */     List Idlist = this.queryList.getList("getUp_org_id", org_id);
/* 361 */     if ((Idlist != null) && (Idlist.size() > 0)) {
/* 362 */       Map chmap = (Hashtable)Idlist.get(0);
/* 363 */       if (chmap.get("up_org_id") != null)
/*     */       {
/* 365 */         up_org_id = chmap.get("up_org_id").toString();
/*     */       }
/*     */     }
/* 368 */     return up_org_id;
/*     */   }
/*     */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.ti_organize.Ti_organizeInfo
 * JD-Core Version:    0.6.0
 */